class SchedStat
  @@cpu_schedstat_names = %w{
    yld_both_empty
    yld_act_empty
    yld_exp_empty
    yld_count
    sched_switch
    sched_count
    sched_goidle
    ttwu_count
    ttwu_local
    cpu_jiffies
    run_delay_jiffies
    pcount
  }
  def initialize()
    @schedstat = Hash.new
    schedstat = IO.readlines("/proc/schedstat")
    schedstat.each do |line|
      next if line =~ /^domain/ # forget domain stats for now
      fields = line.split(' ')
      name = fields.shift
      if (name =~ /^cpu/)
        @@cpu_schedstat_names.each do |counter_name|
          @schedstat["#{name}_#{counter_name}"] = fields.shift
        end
      else
        @schedstat[name] = fields.shift
      end
    end
  end
end
